<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="embroot.css">
<TITLE>
Embedding into Tcl/Tk
</TITLE>
</HEAD>
<BODY >
<A HREF="embroot012.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="embroot026.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H1 CLASS="chapter"><A NAME="htoc33">Chapter&nbsp;5</A>&nbsp;&nbsp;Embedding into Tcl/Tk</H1>
<A NAME="chaptcl"></A>

<BR>
<BR>
This chapter describes how to embed ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> into a Tcl host program.
Tcl/Tk is a cross-platform toolkit for the development of graphical
user interfaces. 
The facilities described here make it possible to implement ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP>
applications with platform-independent graphical user interfaces.
The interface is similar in spirit to the ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> embedding
interfaces for other languages.<BR>
<BR>
An alternative method of using ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> with Tcl is to use the Tcl remote
interface, described in chapter&nbsp;<A HREF="embroot026.html#chapremote">6</A>. In this case, the
ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> is ran as a separate program. The facilities provided by the
remote and embedding interfaces are largely compatible, so that it is
possible to reuse the same Tcl and ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> code in both interface. The
advantage of the embedding interface is that ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> is much more
tightly coupled with the Tcl program, and communication between the two is
more efficient. The advantage of the remote interface is that the Tcl and
ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> programs are not tightly coupled, and in fact can be run on
separate machines. <BR>
<BR>
The <B>tkeclipse</B> development environment is entirely
implemented using the facilities described in this chapter. The toplevel of
<B>tkeclipse</B> is currently implemented using only the embedding interface,
but the development tools can be used with both the embedding and remote
interfaces. <BR>
<BR>
<UL>
<LI><A HREF="embroot017.html">Loading the interface</A>
<LI><A HREF="embroot018.html">Initialising the ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> Subsystem</A>
<LI><A HREF="embroot019.html">Shutting down the ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> Subsystem</A>
<LI><A HREF="embroot020.html">Passing Goals and Control to ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP></A>
<LI><A HREF="embroot021.html">Communication via Queues</A>
<UL>
<LI><A HREF="embroot021.html#toc19">From-ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> to Tcl</A>
<LI><A HREF="embroot021.html#toc20">To-ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> from Tcl</A>
</UL>
<LI><A HREF="embroot022.html">Attaching Handlers to Queues</A>
<UL>
<LI><A HREF="embroot022.html#toc21">Tcl handlers</A>
<LI><A HREF="embroot022.html#toc22">ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> handlers</A>
</UL>
<LI><A HREF="embroot023.html">Obtaining the Interface Type</A>
<LI><A HREF="embroot024.html">Type conversion between Tcl and ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP></A>
<LI><A HREF="embroot025.html">Incompatible and obsolete commands</A>
</UL>

<BR>
<BR>
<HR WIDTH="50%" SIZE=1><DL CLASS="list"><DT CLASS="dt-list"><A NAME="note1" HREF="embroot021.html#text1"><FONT SIZE=5>1</FONT></A><DD CLASS="dd-list">Strictly speaking, flushing is not
necessary in the embedding case to make the data available to the other
side. However, it is needed in the remote case, and for compatibility and
good practice, flushing is recommended.
<DT CLASS="dt-list"><A NAME="note2" HREF="embroot021.html#text2"><FONT SIZE=5>2</FONT></A><DD CLASS="dd-list">For compatibility with previous
 versions of the embedding Tcl interface, the mode can also be
 specified as r (equivalent to fromec) or w (equivalent to
 toec). These can be somewhat confusing as read/write status depends
 on from which side the queue is viewed (a read queue in ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> is a
 write queue in Tcl).
<DT CLASS="dt-list"><A NAME="note3" HREF="embroot022.html#text3"><FONT SIZE=5>3</FONT></A><DD CLASS="dd-list">It is possible to use the same name for both the queue stream itself and
the event. This simplifies the event handler code because it receives that
name as an argument.
</DL>
<HR>
<A HREF="embroot012.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="embroot026.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
